package com.grgbanking.it.system.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.grgbanking.it.base.BaseDao;
import com.grgbanking.it.system.dao.IUserDao;
import com.grgbanking.it.system.entity.User;


/**
 * 
 * @author JRainbow 
 */
@Repository 
public class UserDao extends BaseDao<User, Integer> implements IUserDao<User, Integer> {
    @Autowired  
    public void setMySessionFactory(SessionFactory oaSessionFactory){  
        super.setSessionFactory(oaSessionFactory);  
    }
    
    @Override
    public User getUserByUserId(String userId){
    	StringBuffer hql = new StringBuffer("from User t");
    	hql.append(" where t.userId='").append(userId).append("'");
    	return this.findOneByHQL(hql.toString());
    }


	@Override
	public List<User> findAll() {
		StringBuffer hql = new StringBuffer("from User t where t.notLogin='0'");
		return this.findByHql(hql.toString());
	}

	@Override
	public List<User> findUsersByDeptId(Integer deptId) {
		StringBuffer hql = new StringBuffer("from User t where t.deptId=").append(deptId);
		return this.findByHql(hql.toString());
	}
}